{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "62e8d40c",
   "metadata": {},
   "outputs": [],
   "source": [
    "购物车程序项目：\n",
    "1.运行程序后，让用户输入支付宝余额，然后打印我们的商品列表给用户\n",
    "2.让用户输入商品编号进行购买\n",
    "3.用户选择后，检查用户；余额是否够，若够直接扣款，不够则提醒用户\n",
    "4.用户可以随时退出购买，退出时打印自己购买的商品和支付宝余额"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7c11feed",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-1-99804ab2c3fe>, line 12)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-1-99804ab2c3fe>\"\u001b[1;36m, line \u001b[1;32m12\u001b[0m\n\u001b[1;33m    While true\u001b[0m\n\u001b[1;37m          ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# 1 商品信息\n",
    "good_list = [\n",
    "    [\"milk\", 20],\n",
    "    [\"coffee\" , 30],\n",
    "    [\"tea\",50]\n",
    "]\n",
    "# 用户输入 使用input，结果是个字符串\n",
    "Alipay = int(input(\"请输入您的余额:\"))\n",
    "\n",
    "# 循环遍历商品列表，将商品信息按照一定格式输出\n",
    "#商品编号：xx；商品名称：xx；商品价格：xx\n",
    "While true\n",
    "for i in range(len(goods_list)):\n",
    "    print(\"商品编号:%s , 商品名称:%s , 商品价格:%s\"%(i,goods_list[i][0],goods_list[i][1]))\n",
    "    \n",
    "#\n",
    "choice = input\n",
    "if choice.isdight():\n",
    "    choice = int(choice)\n",
    "    if choice > len(good_list):\n",
    "        print(\"您选择的商品不存在\")\n",
    "    else:\n",
    "        if Alipay > goods_list[choice][1]:\n",
    "            \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f25dca7e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
